/**
 * udes.ds.agent.hw
 * TestingEquation.java
 * 7 oct. 09
 */
package udes.ds.agent;


/** 
 * @author      Luc Bergevin
 * @version     1.0     
 */
public class TestingEquation extends AbstractEquation {
	
	public class ExponentialEquation extends AbstractEquation {

		private static final long	 serialVersionUID	= 1L;
		private double __exponent;

		/**
		 * Equation of the type E^x
		 *
		 * @param _exponent	the exponent for E          
		 */
		public ExponentialEquation(double exponent) {
			super();
			__exponent = exponent;
		}
		
		/**   
		 * @see udes.ds.agent.AbstractEquation#getUserReadableString()      
		 */
		protected String getUserReadableString() {
			return new String("E^" + Double.toString(__exponent));
		}

		/**
		 * @see udes.ds.agent.Equation#getFunctionValue(double)      
		 */
		public double getFunctionValue(double x) {
			return Math.exp(x);
		}
		
	}

	private static final long	 serialVersionUID	= 1L;
	private SummativeEquation _equation;

	/**
	 * Construct an Equation to test the agent system.        
	 */
	public TestingEquation() {
		BasicEquation basic1 = new BasicEquation(4.0,2);
		BasicEquation basic2 = new BasicEquation(8.0,3);
		SummativeEquation sum1 = new SummativeEquation(basic1,basic2);
		
		BasicEquation basic3 = new BasicEquation(5.0,8);
		ExponentialEquation expo1 = new ExponentialEquation(13);
		SummativeEquation sum2 = new SummativeEquation(basic3,expo1);
		
		MultiplicativeEquation mult1 = new MultiplicativeEquation(expo1,sum1);
		MultiplicativeEquation mult2 = new MultiplicativeEquation(basic2, sum2);
		
		_equation = new SummativeEquation(mult1,mult2);
		
	}

	/**   
	 * @see udes.ds.agent.Equation#getFunctionValue(double)      
	 */
	public double getFunctionValue(double x) {
		return _equation.getFunctionValue(x);
	}

	/**  
	 * @see udes.ds.agent.Equation#getUserReadableString()      
	 */
	protected String getUserReadableString() {
		return _equation.getUserReadableString();
	}

	public AbstractEquation getEquation() {
		return _equation;
	}

}
